{
[==================================================]
[            Stupid3ooo's PowerMiner               ]
[                  version:1.2                     ]
[==================================================]
| Instructions:                                    |
|   1.Add Colors/Setup Lines 26-42                 |
|   2.Do not rotate camera, keep relativly north   |
|   3.Highest angle of view, look from above       |
|   4.V-bright,32bit colors                        |
|   5.Public Chat OFF                              |
|   6.SCAR version 1.13                            |
|   7.Silent Mouse OFF                             |
[==================================================]
[ Thanks to, RSCheating community                  ]
[   *PLEASE POST ANY BUGS/HELP IN THE FORUMS       ]
[==================================================]
}
program StupidPowerMiner;

var cmhs,x,y,a,b,flag,Talkto,Mine,MineY,PickHead,
PickHandle,Take,Ore,Drop,NotStuck,Walk,Drops,
Talked,Ran,Attached,Gas:integer;
ST:LongInt;

const
////======================Setup=======================\\\\
Username = '';
Password = '';
Direction = 'X';//(N)orth,(S)outh,(E)ast,(W)est,(X) if ore is right next to minning spot pickaxe
Distance = 30;
//This is to help find the ore according to the minimap.
//Direction is which cardinal dirrecion the ore you want to mine is located from the Minimap Pick Axe.
//The distance is the length in coordinates between the ore and the Minimap Pick Axe, or minning spot icon.
//You can use the eye dropper to help find the distance.
//For an easy refrence go to: http://www.angelfire.com/oz/stupid3ooo/Instruction.JPG
//=\\================================================//=\\

////======================Colors======================\\\\
HeadColor = 2177611;//Pickaxe head color, must be specific color. 2177355/5651002 for bronze/mith
OreColor = 5212583;//Color of ore you wish to mine
MapPick = 7700344;//Color of MINIMAP pickaxe, or minning spot color(choose handle or head color)
//=\\================================================//=\\

Procedure PrintProgressReport; //modified from Phalanx's script
var
  RHours,Minutes,Seconds,RMinutes,RSeconds,avtime:LongInt;
  Time:String;
begin
  Seconds:=(GetSystemTime-ST) div 1000;
  Minutes:=Seconds div 60;
  RHours:=Minutes div 60;
  Time:=inttostr(Seconds)+' Seconds';
  avtime:=Seconds/Drops;
  if Minutes<>0 then
  begin
   RSeconds:=Seconds Mod (Minutes*60);
   Time:=inttostr(Minutes)+' Minutes and '+inttostr(RSeconds)+' Seconds';
  end;
  if RHours<>0 then
  begin
   RMinutes:=Minutes Mod (RHours*60);
   RSeconds:=Seconds Mod (Minutes*60);
   Time:=inttostr(RHours)+' Hours, '+inttostr(RMinutes)+' Minutes and '+inttostr(RSeconds)+' Seconds';
  end;
  begin
  writeln('<=================Progress Report================>');
  writeln('Ran '+inttostr(ran)+' time[s]');
  writeln('Talked '+inttostr(talked)+' time[s]');
  writeln('Attached '+inttostr(attached)+' time[s]');
  writeln('Stopped for gas '+inttostr(attached)+' time[s]');
  writeln('Worked for '+Time);
  writeln('Mined about '+inttostr(drops*28)+' ore[s]');
  writeln('Currently Averaging about '+inttostr(3600/avtime*28)+' ores an hour');
  writeln('<================================================>');
  end;
end;

Procedure ClickMouseHuman(x,y,rx,ry: integer; left:boolean);    { Made By GenoDemoN }
var cx,cy,dm: Integer;
begin
x:=x+random(rx);
y:=y+random(ry);
MoveMouseSmooth(x,y);
Wait(100);
getmousepos(cx,cy);
If (cx=x) and (cy=y) then
dm:=1;
Clickmouse(x,y,left);
If (dm=1) then
cmhs:=cmhs+1;
If (dm=0) then
cmhs:=cmhs+1;
end;

procedure LoginIfNeeded;//A stupid3ooo procedure based of many others
var counter:integer;
begin
if(IsTextAt2(293,251,'Username',10))then
  begin ClickMouseHuman(460,322,10,2,true);Wait(500+random(500));;end;
if(IsTextAt2(309,241,'Welcome to RuneScape',10))then
  begin
  ClickMouseHuman(453,292,20,5,true);
  Wait(500+random(500));
  end;
if(IsTextAt2(293,251,'Username',10))then
  begin
  ClickMouseHuman(400,256,20,5,true);
  Wait(500+random(500));
  SendKeysSilent(username);
  Wait(500+random(500));
  ClickMouseHuman(400,270,20,5,true);
  Wait(500+random(500));
  SendKeysSilent(password);
  Wait(1000+random(500));
  ClickMouseHuman(300,322,20,5,true);
  repeat
  counter:=counter+1
  wait(100);
  until((GetColor(466,61)=8421504)and(GetColor(433,59)=8421504))or(counter=60)
  end;
if((GetColor(466,61)=8421504)and(GetColor(433,59)=8421504))then
  begin
  Wait(500+500);
  ClickMouseHuman(466,64,10,2,true);
  Wait(500+500);
  end;
end;

procedure SetRunOn;
begin
   Wait(50+random(5));
   ClickMouseHuman(708,475,5,5,true);
   Wait(100+random(100));
   ClickMouseHuman(614,260,5,5,true);
   Wait(100+random(10));
   ClickMouseHuman(644,178,5,5,true);
   Wait(100+random(10));
End;

Procedure MapFlag;
begin
   Wait(200);
   if(FindBitmapIn(flag,a,b,565,5,725,160))then
   begin
    repeat
     wait(500);
    until(not FindBitmapIn(flag,a,b,565,5,725,160));
    Wait(100);
   end;
End;

procedure ItemGrab;
var ClickCount:integer;
begin
  if(FindColorSpiral(x,y,241,565,5,725,160))then
    begin
    ClickMouseHuman(x,y,0,0,true);
    MapFlag;
    Wait(100+random(100));
    repeat
    ClickCount:=ClickCount+1
    ClickMouseHuman(220,150,50,50,false);
    Wait(100+random(100));
    if(FindBitmap(Take,x,y))then
      begin
      Wait(500+random(500));
      ClickMouseHuman(x,y,10,2,true);
      Wait(500+random(500));
      break;
      end;
    MoveMouseSmooth(random(50),random(50));
    until(ClickCount=50)
    end;
end;

procedure ReturnToOre;
begin
if(FindColorSpiralTolerance(x,y,MapPick,565,5,725,160,5))then
  begin
  ClickMouseHuman(x,y,5,5,true);
  MapFlag;
  Wait(100+random(100));
  if(direction='N')then
    begin
    ClickMouseHuman(648,83-Distance,5,5,true);
    MapFlag;
    end;
  if(direction='E')then
    begin
    ClickMouseHuman(648+Distance,83,5,5,true);
    MapFlag;
    end;
  if(direction='W')then
    begin
    ClickMouseHuman(648-Distance,83,5,5,true);
    MapFlag;
    end;
  if(direction='S')then
    begin
    ClickMouseHuman(648,83+Distance,5,5,true);
    MapFlag;
    end;
  end;
end;

Procedure FindFight;
begin
if(FindColorSpiral(x,y,65280,180,90,320,230))then wait(1000)
if(FindColorSpiral(x,y,65280,180,90,320,230))then
  begin
  SetRunOn;
  ClickMouseHuman(648,35,5,5,true);
  Wait(100);
  Mapflag;
  Wait(8000+random(2000));
  ClickMouseHuman(648,135,5,5,true);
  MapFlag;
  ReturnToOre;
  Wait(100);
  Ran:=Ran+1
  end;
end;

procedure TalkToRand;
begin
  repeat
  if (FindColorSpiral(x,y,16711680,5,345,510,465))or(FindColorSpiral(x,y,16777215,5,345,510,465))then
      begin
      ClickMouseHuman(x,y,50,2,true);
      wait(2000+random(1000));
      end;
  until(GetColor(20,434)=0)
end;

procedure FindText;
var counter:integer;
begin
if (FindColor(x,y,65535,0,0,515,338))then wait(1000)
if (FindColor(x,y,65535,0,0,515,338))then
  begin
  repeat
    if(FindColorSpiral(x,y,65280,180,90,320,230))then
      begin
      LoginIfNeeded;
      FindFight;
      break;
      end;
    counter:=counter+1
    ClickMouseHuman(x,y,250,10,false);
    wait(100+random(100));
    if(FindBitmap(Talkto,x,y))then
      break;
    MoveMouseSmooth(random(50),random(50));
    until(counter=25);
   if(FindBitmap(Talkto,x,y))then
     begin
     ClickMouseHuman(x,y,10,2,true);
     MapFlag;
     wait(1000+random(1000));
     TalkToRand;
     Talked:=Talked+1
     end;
  end;
end;

procedure AttachPick;
begin
if(FindBitmapSpiralTolerance(PickHead,x,y,550,200,745,465,50))and
(FindBitmapSpiralTolerance(PickHandle,x,y,550,200,745,465,50))then
  begin
  if(FindBitmapSpiralTolerance(PickHead,x,y,550,200,745,465,50))then
    begin
    Attached:=Attached+1
    ClickMouseHuman(x,y,5,5,true);
    Wait(1000+random(100));
    end;
  if(FindBitmapSpiralTolerance(PickHandle,x,y,550,200,745,465,50))then
    begin
    ClickMouseHuman(x,y,5,5,true);
    Wait(1000+random(100));
    end;
  end;
end;

procedure FindPick;
var DropCount,Counter:integer;
begin
if((GetColor(387,382)=0)and(GetColor(485,413)=0))then
begin
  repeat
  DropCount:=DropCount+1
  If(FindBitmapSpiralTolerance(Ore,x,y,550,200,745,465,100))then
  begin
  ClickMouseHuman(x,y,2,2,false);
  Wait(100+random(100));
  if(FindBitmap(Drop,x,y))then
  ClickMouseHuman(x,y,10,2,true);
  Wait(100+random(100));
  MoveMouseSmooth(random(50),random(50));
  Wait(500+random(100));
  end;
  until(DropCount=2);
ClickMouseHuman(683,184,5,5,true);
wait(500+random(100));
ClickMouseHuman(591,303,5,5,true);
wait(500+random(100));
ClickMouseHuman(647,183,5,5,true);
wait(500+random(100));
if(FindColorSpiral(x,y,HeadColor,0,0,515,338))then
  begin
  WriteLn('Found pick at '+IntToStr(x)+','+IntToStr(y));
  ClickMouseHuman(x,y,1,1,false);
  Wait(100+random(100));
  if not(FindBitmap(Take,x,y))then
    begin
    WriteLn('Clicked on a non-axe,grabbing items.');
    repeat
    ItemGrab;
    ReturnToOre;
    Counter:=counter+1
    until(FindBitmapSpiralTolerance(PickHead,x,y,550,200,745,465,50))or(counter=5);
    end;
  if(FindBitmap(Take,x,y))then
    begin
    ClickMouseHuman(x,y,10,2,true);
    MapFlag;
    Wait(2000+random(1000));
    end;
  end;
  if not(FindColorSpiral(x,y,HeadColor,0,0,515,338))and
  not(FindBitmapSpiralTolerance(PickHead,x,y,550,200,745,465,50))then
  begin
  WriteLn('Can not find pickhead in screen,grabbing items.');
  repeat
  ItemGrab;
  ReturnToOre;
  counter:=counter+1
  until(FindBitmapSpiralTolerance(PickHead,x,y,550,200,745,465,50))or(counter=5);
  end;
end;
AttachPick;
end;

Procedure FindGas;
var GasColor,GasCount,counter,GT:integer;
begin
GT:= 20;
GasColor:=7377570;//7377570
if(FindColorSpiralTolerance(x,y,GasColor,180,90,320,230,GT))then
  begin
  Gas:=Gas+1
  WriteLn('Found Gas at ('+IntToStr(x)+','+IntToStr(y)+')');
  Wait(100+random(100));
  ClickMouseHuman(244,168,5,5,false);
  Wait(100+random(100));
  if(FindBitmap(Walk,x,y))then ClickMouseHuman(x,y,10,2,True);
  repeat
  wait(100);
  if(IsTextAt2(293,251,'Username', 100))or
  (IsTextAt2(309,241,'Welcome to RuneScape', 100))then
  begin LoginIfNeeded; break; end;
  FindFight;
  FindText;
  counter:=counter+1
  if not(FindColorSpiralTolerance(x,y,GasColor,180,90,320,230,GT))then
    begin
    repeat
    wait(100);
    if(FindColorSpiralTolerance(x,y,GasColor,180,90,320,230,GT))then
      begin GasCount:=0; break; end;
    if not(FindColorSpiralTolerance(x,y,GasColor,180,90,320,230,GT))then
      begin GasCount:=GasCount+1 end;
    until(GasCount=10);
    end;
  if(GasCount=10)then begin WriteLn('Gas is gone'); break; end;
  until(counter>600)
  end;
end;

Procedure FindRandoms;
begin
LoginIfNeeded;
FindFight;
FindText;
FindPick;
FindGas;
end;

Procedure InvDrop;
var counter:integer;
begin
Drops:=Drops+1
SetRunOn;
ClickMouseHuman(648,35,5,5,true);
Mapflag;
wait(100+random(100));
repeat
  counter:=counter+1
  If(FindBitmapSpiralTolerance(Ore,x,y,550,200,745,465,100))then
    begin
    ClickMouseHuman(x,y,5,5,false);
    Wait(100+random(100));
    if(FindBitmap(Drop,x,y))then
      begin
      ClickMouseHuman(x,y,10,2,true);
      Wait(100+random(100));
      end;
    MoveMouseSmooth(650+random(10),185+random(10));
    Wait(500+random(100));
    end;
until(not(FindBitmapSpiralTolerance(Ore,x,y,550,200,745,465,100)))or(counter=75)
ClickMouseHuman(648,135,5,5,true);
Mapflag;
wait(100+random(100));
end;

Procedure MineOre;
var counter:integer;
begin
if(FindColoredAreaTolerance(x,y,OreColor,0,0,515,338,25,5))then
  begin
  ClickMouseHuman(x,y,2,2,false);
  Wait(200+random(100))
  If(FindBitmapSpiralTolerance(Mine,x,y,0,0,515,338,0))or
  (FindBitmapSpiralTolerance(MineY,x,y,0,0,515,338,0))then
    begin
    ClickMouseHuman(x,y,10,2,true);
    MapFlag;
    Wait(100+random(100));
    repeat
    counter:=counter+1
    FindRandoms;
    Wait(100)
    until not((GetColor(195,426)=0)and(GetColor(109,430)=0))or(counter=20);
    end;
  MoveMouseSmooth(50,50);
  end;
end;

Procedure LoadBmps;
begin
flag := BitmapFromString(2, 2,
        'FF00005D3311C656045D3311');
Talkto := BitmapFromString(18, 2,
       'FFFFFFFFFFFF000000FFFFFFFFFFFF5D54475D54475D54475D5447' +
       '5D54475D54475D54475D54475D5447FFFFFFFFFFFFFFFFFFFFFFFF' +
       'FFFFFFFFFFFFFFFFFFFFFFFF0000000000005D5447FFFFFFFFFFFF' +
       'FFFFFFFFFFFFFFFFFF5D54475D5447FFFFFFFFFFFF000000000000' +
       '');
Walk := BitmapFromString(20, 2,
       'FFFFFF0000000000005D5447FFFFFFFFFFFF0000005D5447FFFFFF' +
       'FFFFFF0000005D5447FFFFFFFFFFFF0000005D5447FFFFFFFFFFFF' +
       '000000FFFFFF0000000000005D54475D54475D5447FFFFFFFFFFFF' +
       'FFFFFFFFFFFFFFFFFF0000005D5447FFFFFFFFFFFF0000005D5447' +
       'FFFFFFFFFFFF0000005D5447');
Take := BitmapFromString(20, 2,
       '5D5447FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000005D5447FFFFFF' +
       'FFFFFFFFFFFF0000000000005D54475D5447FFFFFFFFFFFF000000' +
       '5D5447FFFFFFFFFFFFFFFFFF000000000000FFFFFFFFFFFF000000' +
       '5D5447FFFFFFFFFFFFFFFFFFFFFFFF5D54475D54475D5447FFFFFF' +
       'FFFFFFFFFFFFFFFFFFFFFFFF');
Mine := BitmapFromString(40, 2,
       'FFFFFFFFFFFF0000005D54475D54475D5447FFFFFFFFFFFF000000' +
       '5D5447FFFFFFFFFFFF0000005D5447FFFFFFFFFFFF0000005D5447' +
       'FFFFFFFFFFFF0000005D5447FFFFFFFFFFFF000000000000000000' +
       '0000005D54475D54475D54475D54475D54475D544700FFFF00FFFF' +
       '0000005D544700FFFF00FFFFFFFFFFFFFFFF0000005D54475D5447' +
       '5D5447FFFFFFFFFFFF0000005D5447FFFFFFFFFFFF0000005D5447' +
       'FFFFFFFFFFFF0000005D5447FFFFFFFFFFFF0000005D54475D5447' +
       'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D54475D54475D54475D5447' +
       '5D54475D544700FFFF00FFFF0000005D544700FFFF00FFFF');
MineY := BitmapFromString(40, 2,
       'FFFF00FFFF000000005D54475D54475D5447FFFF00FFFF00000000' +
       '5D5447FFFF00FFFF000000005D5447FFFF00FFFF000000005D5447' +
       'FFFF00FFFF000000005D5447FFFF00FFFF00000000000000000000' +
       '0000005D54475D54475D54475D54475D54475D544700FFFF00FFFF' +
       '0000005D544700FFFF00FFFFFFFF00FFFF000000005D54475D5447' +
       '5D5447FFFF00FFFF000000005D5447FFFF00FFFF000000005D5447' +
       'FFFF00FFFF000000005D5447FFFF00FFFF000000005D54475D5447' +
       'FFFF00FFFF00FFFF00FFFF00FFFF005D54475D54475D54475D5447' +
       '5D54475D544700FFFF00FFFF0000005D544700FFFF00FFFF');
Drop := BitmapFromString(20, 2,
       'FFFFFFFFFFFF0000005D5447FFFFFFFFFFFF0000005D5447FFFFFF' +
       'FFFFFF0000005D54475D54475D5447FFFFFFFFFFFF0000005D5447' +
       'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000000' +
       '5D5447FFFFFFFFFFFF0000005D54475D54475D54475D5447FFFFFF' +
       'FFFFFFFFFFFFFFFFFF000000');
Ore := BitmapFromString(10, 10,
       '856C4B856C4B886E4D8B704F000001000001000001000001443827' +
       '584731856C4B886E4D000001000001302020302020000001382D1E' +
       '54442F68543B0000010000013020203020203020200000012D2518' +
       '483B296C573D6F593E302020302020302020544A3C544A3C000001' +
       '3D31225847316F593E725C40302020544A3C564D41544A3C564D41' +
       '0000014D3E2B6F593E755E43776044544A3C544A3C564D41564D41' +
       '564D41000001584731725C407760447A6346544A3C544A3C564D41' +
       '564D41564D41000001655239755E437A6346806748544A3C564D41' +
       '544A3C544A3C564D410000016F593E7A6346806748886E4D544A3C' +
       '544A3C544A3C4F4538544A3C544A3C000001000001000001000001' +
       '564D41564D41564D41544A3C4F4538544A3C564D41302020302020' +
       '302020');
PickHandle := BitmapFromString(15, 27,
       '564D41595145564D41544A3C544A3C595145564D41564D41564D41' +
       '564D41595145000001000001544A3C4F4538544A3C595145564D41' +
       '544A3C544A3C544A3C5951455951455951455951450000012F2000' +
       '362400000001544A3C564D41544A3C544A3C564D41564D41564D41' +
       '5951455951455951450000012F20002F2000362400000001302020' +
       '564D41544A3C544A3C595145564D41595145564D41595145595145' +
       '0000012F2000362400362400000001302020564D41564D41564D41' +
       '564D41564D41544A3C544A3C544A3C0000012F20002F2000362400' +
       '362400000001302020544A3C544A3C544A3C544A3C544A3C544A3C' +
       '544A3C544A3C0000012F2000362400362400362400000001302020' +
       '544A3C564D41564D41564D41544A3C564D41564D410000012F2000' +
       '2F2000362400362400000001302020302020564D41564D41564D41' +
       '595145564D41564D41564D410000012F2000362400362400000001' +
       '302020302020544A3C544A3C544A3C544A3C595145544A3C544A3C' +
       '0000012F2000362400362400362400000001302020564D41564D41' +
       '544A3C544A3C544A3C564D41544A3C4F45380000012F2000362400' +
       '362400000001302020302020564D41564D41544A3C544A3C595145' +
       '595145564D410000012F2000362400362400362400000001302020' +
       '564D41564D41544A3C544A3C564D41564D41595145595145000001' +
       '2F20002F20002F2000000001302020302020564D41564D41544A3C' +
       '564D41564D41544A3C564D410000012F20002F20002F2000362400' +
       '000001302020564D41544A3C544A3C544A3C595145544A3C544A3C' +
       '564D410000012F20002F20002F2000000001302020302020544A3C' +
       '544A3C564D41564D41595145544A3C544A3C0000012F20002F2000' +
       '2F2000000001302020302020595145544A3C564D41595145595145' +
       '595145564D41564D410000012F20002F20002F2000000001302020' +
       '595145595145564D41564D41595145595145595145595145000001' +
       '2F20002F20002F2000000001302020302020595145595145595145' +
       '595145564D41564D41564D41564D410000012F20002F20002F2000' +
       '000001302020564D41595145595145595145595145564D41564D41' +
       '544A3C0000012F20002F20002F2000000001302020302020564D41' +
       '595145595145544A3C544A3C564D41595145564D410000012F2000' +
       '2F20002F2000000001302020544A3C564D41595145595145544A3C' +
       '544A3C564D41564D41564D410000012F20002F2000000001302020' +
       '302020544A3C564D41595145595145564D41544A3C544A3C4F4538' +
       '000001271B002F20002F2000000001302020595145544A3C564D41' +
       '595145595145595145544A3C544A3C544A3C0000011D1500271B00' +
       '000001302020302020595145544A3C564D41595145595145595145' +
       '564D41564D41564D410000011D15001D1500000001302020595145' +
       '544A3C544A3C564D41595145595145595145595145595145544A3C' +
       '0000011D15001D1500000001302020564D41595145595145595145' +
       '595145564D41595145595145564D41544A3C564D41000001000001' +
       '302020302020595145595145595145595145544A3C564D41595145' +
       '544A3C544A3C4F4538564D41595145302020302020564D41595145' +
       '564D41564D41564D41544A3C544A3C564D41544A3C544A3C544A3C' +
       '');
PickHead := BitmapFromString(6, 5,
       '2E1F002E1F00352400000001483E33483E331D1400261A002E1F00' +
       '352400000001483E331D14001D1400261A002E1F00000001302020' +
       '000001000001000001000001302020302020302020302020302020' +
       '302020302020483E33');
end;
begin
LoadBmps;
LoadChars('');
ST:=GetSystemTime;
repeat
NotStuck:=NotStuck+1;
if(NotStuck=250)then
  begin
  ReturnToOre;
  NotStuck:=0;
  end;
if((GetColor(205,391)=0)and(GetColor(422,398)=0))or//iron
((GetColor(430,398)=0)and(GetColor(196,391)=0))then//copper
  begin
  WriteLn('Dropping Inventory');
  InvDrop;
  PrintProgressReport;
  ReturnToOre;
  end;
LoginIfNeeded;
FindRandoms;
MineOre;
Wait(100+random(100));
until(false)
end.
